#include "comment.h"
#include "system.h"
#include "list.h"
#include "ticket.h"
int main(int argc,const char * argv[])
{
    int menu = 1;
    while (menu) //持续打开首页菜单
    {
        char * re = showSelect("UI/menu");
        if (strcmp(re,"1")==0)  //判断选项，1则进行用户操作
        {
            system("clear");
            while(menu){    
            char * us = showSelect("UI/USER/userPage");  //打开用户方页面
            if (strcmp(us,"1")==0)        //用户登录
            {
                system("clear");
                if(userLogin()==1){    //判断登录是否成功 
                 while (menu)
                 {
                  char * uM =  showSelect("UI/USER/useManage");  //打开用户操作页面
                  if (strcmp(uM,"1")==0)
                  {
                    while (menu)
                    {system("clear");
                        char * uMH = showSelect("UI/USER/useManH"); //打开了用户查询方式页面
                        if (strcmp(uMH,"1")==0)
                        {
                           display();
                        // }else if (strcmp(uMH,"2")==0)
                        // {
                        //   sortPrice();
                        }else
                        {
                          break;
                          system("clear");
                        }
                        
                        
                    }
                  }else if (strcmp(uM,"2")==0)      //购票
                  {
                    buyTicket();
                  }else if (strcmp(uM,"3")==0)    //查询余额
                  {
                    budget();
                  }else if (strcmp(uM,"4")==0)    //修改密码
                  {
                    change();
                  }else if (strcmp(uM,"5")==0)    //充值
                  {
                    cz();
                  }else 
                  {
                    system("clear");
                    break;
                  }
                  
                 }

                }
            }else if (strcmp(us,"2")==0)
            {
                system("clear");
                userRegist();
            }else{
                system("clear");
                break;
            }
            }
            
        }else if (strcmp(re,"2")==0) //判断选项，2则进行管理员操作
        {
            system("clear");
            while(menu){   //持续打开
            char * ad =showSelect("UI/admin/adminstrator"); //管理员页面
            if (strcmp(ad,"1")==0)
            {
                system("clear");
                if(adminLogin()==1){
                    while(menu){//持续打开
                    char * adm = showSelect("UI/admin/adminManage"); //管理员管理页面
                    if (strcmp(adm,"1")==0){
                        system("clear");
                        while (menu) //持续打开
                        {
                          char * tm = showSelect("UI/admin/ticketManage");//车票管理页面
                          if (strcmp(tm,"1")==0)       //查看车票
                          {
                            display();
                          }else if (strcmp(tm,"2")==0)  //添加车票
                          {
                            addTicket();
                          }else if (strcmp(tm,"3")==0)   //删除车票
                          { 
                            deleteTicket();
                          }else if (strcmp(tm,"4")==0)   //修改车票
                          { 
                            alterTicket();
                          }else {                 //返回或退出
                            system("clear");
                            break;
                          }
                        }
                    }else if (strcmp(adm,"2")==0)
                    {
                        showUser();
                    }else if (strcmp(adm,"0")==0)
                    {
                        system("clear");
                        break;
                    }
                    }
                }
            }else{
                system("clear");
                break;
            }
            }
        }else if (strcmp(re,"0")==0)
        {
            system("clear");
            return 0;
        }
    }
    return 0;
}